package com.baizhi.controller;

import com.baizhi.service.UserService;
import com.baizhi.service.UserThreadService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/4/4.
 */
@RequestMapping("/User")
@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private UserThreadService userThreadService;

    @RequestMapping("/selectAllUser.do")
    @ResponseBody
    public Map selectAllUser(int rows,int page,String username){
        System.out.println("00000000000user");
        return userService.selectAllUser(rows,page,username);
    }

    @ResponseBody
    @RequestMapping("/selectSexCount.do")
    @RequiresPermissions(value = "sex:show")
    public Map selectSexCount(){
        return userService.selectSexCount();
    };

    @ResponseBody
    @RequestMapping("/selectAddressCount.do")
    public List<Map> selectAddressCount(){
        return userService.selectAddressCount();
    };


    @ResponseBody
    @RequestMapping("/selectDayCount.do")
    public Map selectDayCount(){
        return userService.selectDayCount();
    };


    @ResponseBody
    @RequestMapping("/selectAllCount1.do")
    public Map selectAllCount(){
        long start = System.currentTimeMillis();
        Map map = userThreadService.selectAllCount1();
        long end = System.currentTimeMillis();
        System.out.println(end-start+"ms");
        return map;
    };

    @ResponseBody
    @RequestMapping("/selectAllCount2.do")
    public Map selectAllCount2(){
        long start = System.currentTimeMillis();
        Map map = null;
        try {
            map = userThreadService.selectAllCount2();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start+"ms");
        return map;
    };


}
